﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;


namespace RadioThermostat
{
    public class RTUtils
    {
        public static string GetURL(RTThermostat thermostat, string command)
        {
            return "http://" + thermostat.IP + "/" + command;
        }

        public static T GetSingleDictionaryVal<T>(IJSONDecoder decoder, string jason)
        {
            Dictionary<string, T> tmp = decoder.Deserialize<Dictionary<string, T>>(jason);
            foreach (string key in tmp.Keys)
            {
                return tmp[key];
            }
            throw new Exception("could not find element.");
        }

        public static T GetSingleDictionaryVal<T>(IJSONDecoder decoder, string jason, string key)
        {
            Dictionary<string, T> tmp = decoder.Deserialize<Dictionary<string, T>>(jason);
            return tmp[key];
        }
    }
}
